package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.DocumentForm;
import com.springboot.cloud.demos.entity.po.Document;
import com.springboot.cloud.demos.ribbon.service.DocumentService;
import com.springboot.cloud.demos.ribbon.service.LessonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class DocumentController {

    @Autowired
    private DocumentService documentService;

    @GetMapping("/document")
    public Result query(@RequestParam("unitId") String unitId, @RequestParam("page") Integer page) {
        return documentService.query(unitId, page);
    }

    @GetMapping("/document/queryByUnit")
    public Result queryByUnit(@RequestParam("unitId") String unitId) {
        return documentService.queryByUnit(unitId);
    }

    @PostMapping("/document")
    public Result add(@RequestBody DocumentForm documentForm) {
        return documentService.save(documentForm);
    }

    @GetMapping("/document/{id}")
    public Result get(@PathVariable(value = "id") String id) {
        return documentService.get(id);
    }
}
